#include "Vector4.h"
#include "Vector3.h"
#include <iostream>


using namespace std;
using namespace prog3d;

float Vector4::_fc[4];

void Vector4::init() {
}

Vector4::Vector4() {
    init();
}

Vector4::Vector4(const Vector3 &p,double w) {
    init();
    this->set(p,w);
}

Vector4::Vector4(const Vector4 &p) {
    init();
    this->set(p);
}

Vector4::Vector4(double x,double y,double z,double w) {
    init();
    _c[0]=x;_c[1]=y;_c[2]=z;_c[3]=w;
}

Vector4::~Vector4() {}

void Vector4::set(const Vector3 &p,double w) {
    _c[0]=p.x();
    _c[1]=p.y();
    _c[2]=p.z();
    _c[3]=w;
}



void Vector4::set(const Vector4 &p) {
    _c[0]=p.x();
    _c[1]=p.y();
    _c[2]=p.z();
    _c[3]=p.w();
}



const float *Vector4::fv() const {
    _fc[0]=_c[0];_fc[1]=_c[1];_fc[2]=_c[2];_fc[3]=_c[3];
    return _fc;
}

void Vector4::print(string mesg) const {
    cout << mesg << "(" << _c[0] << "," << _c[1] << "," << _c[2] << "," << _c[3] << ")\n";
}

Vector3 Vector4::project() {
  Vector3 res;
  res.set(this->x(),this->y(),this->z());
  res.scale(this->w());
  return res;
}

ostream& prog3d::operator <<(ostream &s,const Vector4 &p) {
    s << "(" << p.x() << "," << p.y() << "," << p.z() << "," << p.w() << ")";
    return s;
}



